/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* 登录页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header h1 {
    color: #007bff;
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.login-header p {
    color: #6c757d;
    font-size: 1rem;
    margin-bottom: 30px;
}

.login-form {
    margin-bottom: 30px;
}

.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.input-group input:focus {
    outline: none;
    border-color: #007bff;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.input-hint {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 5px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #f5c6cb;
    font-size: 0.9rem;
}

.login-footer {
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

.feature-list {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
    color: #6c757d;
}

.feature-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #6c757d;
}

.status-item {
    display: flex;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.online {
    background: #28a745;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.online-count {
    font-weight: 600;
    color: #007bff;
}

/* 聊天页面样式 */
.chat-container {
    display: flex;
    height: 100vh;
    background: #f8f9fa;
}

.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #007bff;
    color: white;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.sidebar-header .user-info {
    font-size: 0.9rem;
    opacity: 0.9;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.user-list h3 {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 5px;
    transition: background 0.2s ease;
}

.user-item:hover {
    background: #f8f9fa;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #007bff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 10px;
    font-size: 0.8rem;
}

.user-name {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
}

.user-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
}

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chat-header h2 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 5px;
}

.chat-header .chat-info {
    font-size: 0.9rem;
    color: #6c757d;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message.other .message-bubble {
    background: white;
    border: 1px solid #e9ecef;
    text-align: left;
}

.message.own .message-bubble {
    background: #007bff;
    color: white;
    text-align: left;
}

.message.system .message-bubble {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    font-style: italic;
    text-align: center;
    max-width: 100%;
}

.message-header {
    font-size: 0.8rem;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message.other .message-header {
    color: #007bff;
    font-weight: 600;
}

.message.own .message-header {
    color: rgba(255, 255, 255, 0.8);
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
}

.input-container {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.input-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    font-size: 0.95rem;
    resize: none;
    max-height: 100px;
    min-height: 44px;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.message-input:focus {
    outline: none;
    border-color: #007bff;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.send-btn {
    padding: 12px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.send-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        order: 2;
    }
    
    .main-chat {
        order: 1;
        height: calc(100vh - 200px);
    }
    
    .login-card {
        padding: 30px 20px;
    }
    
    .feature-list {
        flex-direction: column;
        gap: 10px;
    }
    
    .feature-item {
        flex-direction: row;
        justify-content: flex-start;
    }
    
    .feature-icon {
        margin-right: 10px;
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .login-card {
        margin: 10px;
        padding: 20px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .input-form {
        flex-direction: column;
        gap: 10px;
    }
    
    .send-btn {
        width: 100%;
    }
}

/* 滚动条样式 */
.messages-container::-webkit-scrollbar,
.user-list::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.user-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb,
.user-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.user-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 连接状态指示器 */
.connection-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 1000;
    transition: all 0.3s ease;
}

.connection-status.connected {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.connection-status.disconnected {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.connection-status.connecting {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}